<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username">
    <input type="text" id="passworld">

    <script>
            var username=document.getElementById("username");
            username.onkeydown=function(e){
                console.log(e.target.value); //value属性就是输入框的数据
            }

            username.onkeyup=function(e){
                console.log(e.target.value);
            }

            username.onkeypress=function(){
                console.log("keypress");
            }

            var passworld=document.getElementById("passworld")
                passworld.onkeyup=function(e){
                    //keyCode:代表每个案件的唯一标识
                    console.log(e.keyCode); 
                    if(e.keyCode==13){
                        console.log("开始搜索");
                    }
                }
            
    </script>

</body>
</html>